package com.bobo.web.provider.controller.web;

import com.bobo.web.api.domain.video.PictureDO;
import com.bobo.web.api.vo.PictureVO;
import com.bobo.web.api.vo.VideoVO;
import com.bobo.web.api.vo.base.ResponseResult;
import com.bobo.web.provider.service.VideoAndPictureService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("web")
public class PictureController {
    @Resource
    private VideoAndPictureService videoAndPictureService;

    /**
     * 获取图片列表
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getPictureList", method = {RequestMethod.GET})
    public String getPictureList(@RequestParam(value = "gameId",required = false) String gameId, Model model) throws Exception {
        PictureDO params = new PictureDO();
        params.setGameId("1");
        params.setPicType(1);
        ResponseResult<List<PictureVO>> pictureList = videoAndPictureService.getPictureList(params);
        ResponseResult<List<VideoVO>> videoList = videoAndPictureService.getVideoList(gameId);
        model.addAttribute("pictureList",pictureList.getData());
        model.addAttribute("videoList",videoList.getData());
        return "picture_list";
    }
    /**
     * 获取图片列表3D
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getPictureList3d", method = {RequestMethod.GET})
    public String getPictureList3d(@RequestParam String gameId, Model model) throws Exception {
        model.addAttribute("picUrl","http://img.cdn.brobball.top/1564128485399");
        return "picture_list_3d";
    }
    /**
     * 获取图片列表3D
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getPictureList3dd", method = {RequestMethod.GET})
    public String getPictureList3dd(@RequestParam String gameId, Model model) throws Exception {
        PictureDO params = new PictureDO();
        params.setGameId(gameId);
        params.setPicType(1);
        ResponseResult<List<PictureVO>> pictureList = videoAndPictureService.getPictureList(params);
        params.setPicType(3);
        ResponseResult<List<PictureVO>> musicList = videoAndPictureService.getPictureList(params);
        ResponseResult<List<VideoVO>> videoList = videoAndPictureService.getVideoList(gameId);
        model.addAttribute("pictureList",pictureList.getData());
        if(!CollectionUtils.isEmpty(videoList.getData())){
            model.addAttribute("videoList",videoList.getData());
        }
        if(!CollectionUtils.isEmpty(videoList.getData())){
            model.addAttribute("music",musicList.getData().get(0));
        }
        model.addAttribute("picUrl","http://img.cdn.brobball.top/15640296102365");
        return "picture_list_3d";
    }
}
